package com.itheima.health.dao;

import com.itheima.health.dto.MemberParam;
import com.itheima.health.dto.OrderParam;
import com.itheima.health.dto.OrderSettingParam;
import com.itheima.health.dto.OrderSubmitParam;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Order;
import com.itheima.health.pojo.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Mapper
public interface UserOperateDao {
    /**
     * 存入验证码
     */
    @Insert("insert into t_verificationcode(telephone, validateCode, validateCodeTime) VALUE " +
            " (#{telephone}, #{validateCode}, #{validateCodeTime})")
    void addValidateCode(MemberParam memberParam);

    /**
     * 根据手机号查询记录
     */
    @Select("select * from t_verificationCode where telephone = #{telephone}")
    MemberParam getBytelephone(MemberParam memberParam);

    /**
     * 获取超时验证码
     */
    @Select("select * from t_verificationcode where validateCodeTime <= #{time}")
    List<MemberParam> getByExceedsTime(LocalDateTime time);

    /**
     * 删除超时验证码
     */
    @Update("update t_verificationcode set validateCode = null, validateCodeTime = null, telephone = null where validateCodeTime <= #{time}")
    void deleteVerificationCode(LocalDateTime time);

    @Select("select * from t_setmeal")
    List<Setmeal> selectAll();

    List<CheckGroup> getCheckBySetmeal(Setmeal setmeal);
    /*
     * 页面项目展示-用户
     * */
    Setmeal getSetmeal(Integer id);
    /*
     * 查询套餐数据
     * */
    List<CheckItem> getitemByCheckGroup(CheckGroup checkGroup);
    /*
     * 提交预约
     * */

    void submit(OrderSubmitParam orderSubmitParam);

    @Select("Select * from t_ordersetting where orderDate = #{orderDate} ")
    OrderSettingParam query(Date orderDate);

    @Select("Select * from t_verificationcode where telephone = #{telephone}")
    MemberParam queryCode(String telephone);

    void increase(Order order);
    @Select("select * from t_order where id = #{id}")
    OrderParam findOrderByid(Integer id);


}
